{include file="public/head"/}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">短信配置</div>
                <div class="layui-card-body">
                    <div class="layui-form" wid100 lay-filter="form">
                        <div class="layui-form-item">
                            <label class="layui-form-label">HOST</label>
                            <div class="layui-input-inline">
                                <input type="text" name="host" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">如：dysmsapi.aliyuncs.com</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">KEY</label>
                            <div class="layui-input-inline">
                                <input type="text" name="access_key_id" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">access_key_id</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">SECRET</label>
                            <div class="layui-input-inline" style="width: 280px;">
                                <input type="text" name="access_key_secret" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">access_key_secret</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">地区ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="region_id" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">region_id 阿里云一般为：cn-hangzhou</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">短信签名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="sign_name" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">如：成都***网络科技</div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="set_aliyun_sms">确认保存</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/foot"/}
<script>
    layui.config({
        base: '__LAYDMIN__/', {if config('app.app_debug')}version: true{/if}
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'admin'], function () {
        var form = layui.form, admin = layui.admin;
        form.val("form", {$info|raw})
        //提交
        form.on('submit(set_aliyun_sms)', function (obj) {
            admin.req({
                url: '{:url(SYS_PATH."/".CONTROLLER."/alisms")}'
                , data: obj.field
                , type: 'post'
                , success: function (res) {
                    if (res.code == 0) {
                        window.top.layer.msg(res.msg, {icon: 1, time: 1000,shade:[0.5,'#000']});
                    } else {
                        window.top.layer.msg(res.msg, {icon: 2, time: 1000,shade:[0.5,'#000']});
                    }
                }
            });
            return false;
        });

        //发送邮件服务
        form.on('submit(trySend)', function (obj) {
            var divIndex = window.top.layer.load(0,{shade:[0.5,'#000']});
            admin.req({
                url: '{:url(SYS_PATH."/".CONTROLLER."/trySend")}'
                , data: obj.field
                , type: 'post'
                , success: function (res) {
                    window.top.layer.close(divIndex);    //返回数据关闭loading
                    if (res.code == 0) {
                        window.top.layer.msg(res.msg, {icon: 1, time: 1000,shade:[0.5,'#000']});
                    } else {
                        window.top.layer.msg(res.msg, {icon: 2, time: 1000,shade:[0.5,'#000']});
                    }
                }
            });
            return false;
        });

    });
</script>
</body>
</html>
